using Popw.LiveBlog.Config;
using Popw.LiveBlog.Repositories.Cache;
using Popw.LiveBlog.Services;
using StructureMap;

namespace Popw.LiveBlog.DependencyResolution
{
	public static class IoC
	{
		public static IContainer Initialize()
		{
			ObjectFactory.Initialize(x =>
			                         {
				                         x.Scan(scan =>
				                                {
					                                scan.TheCallingAssembly();
					                                scan.WithDefaultConventions();
				                                });
				                         if (Settings.IsAzure)
					                         x.For<ICacheProvider>().Use<AzureCacheProvider>();
				                         else
											 x.For<ICacheProvider>().Use<LocalCacheProvider>();
										 x.ForSingletonOf<ITimeFormattingService>().Use<TimeFormattingService>();
			                         });
			return ObjectFactory.Container;
		}
	}
}